using System;
using System.Collections.Generic;
using Illinois.Core.Interfaces;

namespace Illinois.Core.Models
{
  // todo: where do I have to put this class? is this the right folder or not?
  public class BurnDownFactory : IBurnDownFactory
  {
    public BurnDown MakeBurnDown(string title, DateTime start, DateTime end, int initialStoryPoints)
    {
      var burnDown = new BurnDown();
      burnDown.Title = title;
      burnDown.Start = start;
      burnDown.End = end;
      burnDown.InitialStoryPoints = initialStoryPoints;
      burnDown.Labels = MakeLabels(start, end);
      return burnDown;
    }

    private IEnumerable<string> MakeLabels(DateTime start, DateTime end)
    {
      var list = new List<string>();
      for(var day = start.Date; day <= end; day = day.AddDays(1))
      {
        if(day.DayOfWeek != DayOfWeek.Saturday && day.DayOfWeek != DayOfWeek.Sunday)
          list.Add(day.ToString("dd/MM"));
      }
      return list;
    }
  }
}
